require 'watir'
include Watir
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
require 'watir/testcase'
require 'watir/contrib/enabled_popup'
class TC_Forums < Test::Unit::TestCase
  def test_23
    $ie.goto($UniVar)
    $ie.refresh()

    $ie.link(:text, 'Control Panel').click
    $ie.link(:text, 'Administration').click
    $ie.table(:index, 7).click
    $ie.link(:index, 13).click
    $ie.wait()
    $ie.text_field(:index, 1).value = "ztemp forum"
    $ie.link(:text, 'Save').click
    $ie.link(:text, 'Exit Control Panel and Return to Site').click
    
    $ie.link(:text, 'Forums').click
    $ie.link(:text, 'ztemp forum').click
    
    $ie.link(:text, 'Write a New Post').click
    
    
    $ie.text_field(:index, 2).value = "temp subject"
    temp_var = "temp body"
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")            
    $ie.image(:title, 'Insert/edit image').click

    ie2 = Watir::IE.attach(:url, 'http://localhost/cs/tiny_mce/jscripts/tiny_mce/themes/CommunityServer/image.htm?src=')
    ie2.text_field(:index, 1).value = "http://www.ase.com/Graphics/ASE_home1d_on_cutup/images/ase1d_on_cutup_06.gif"
    ie2.button(:caption, 'Insert').click

    $ie.button(:id, /ctl00_ctl00_bcr_bcr_PostForm_ctl04_PostButton/).click
#    $ie.button(:id, /ctl00_ctl01_bcr_PostForm___PostButton/).click
    
    
    
    $ie.link(:text, 'Sign out').click
    $ie.link(:text, 'Join').click
    
    $ie.text_field(:index, 2).set('temp1')
    $ie.text_field(:index, 3).set('temp11')
    $ie.text_field(:index, 4).set('temp11')
    $ie.text_field(:index, 5).set('temp1@telligent.com')
    $ie.text_field(:index, 6).set('temp1@telligent.com')
    
    $ie.button(:id, /ctl00_bcr_ctl01_ctl00_CreateAccount/).click
#    $ie.button(:id, /ctl00_bcr_ctl00___CreateAccount/).click
    
    $ie.link(:text, 'Forums').click
    $ie.link(:text, 'ztemp forum').click
    $ie.link(:text, 'temp subject').click
    $ie.link(:text, 'Contact').click
    $ie.cell(:text, 'Send ' + $ADMIN + ' an email').click
    $ie.frame(:index, 1).text_field(:index, 1).value = "email subject value"
    $ie.frame(:index, 1).document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")            
    $ie.frame(:index, 1).button(:index, 1).click
    
    
    
    
    $ie.link(:text, 'Sign out').click
    $ie.refresh()
    $ie.link(:text, 'Sign in').click
    $ie.text_field(:id, /username/ ).set($ADMIN)
    $ie.text_field(:id, /password/ ).set($PASSWORD)

    $ie.link(:id, /ctl00_bcr_ctl00_ctl03_loginButton/).click     
#    $ie.link(:id, /ctl00_bcr_Login1___loginButton/).click

      $ie.goto($UniVar + '/controlpanel/forums/Forums.aspx')
      $ie.div(:index, 62).click
      $ie.div(:index, 62).click    
      $ie.link(:text, 'Delete').click_no_wait
      hwnd = $ie.enabled_popup(20)
        if(hwnd)
          w = WinClicker.new
          w.clickWindowsButton_hwnd(hwnd, "OK")
        end
        
      $ie.goto($UniVar + '/ControlPanel/Membership/membersearch.aspx?SelectedNavItem=BrowseMembers')
      $ie.div(:index, 141).click
      $ie.div(:index, 141).click
      $ie.link(:text, 'Actions').click
      $ie.cell(:id, /Menu_3$/).click
      $ie.frame(:index, 6).radio(:index, 2).set
      $ie.frame(:index, 6).button(:caption, 'Delete User').click

      $ie.link(:text, 'Inbox').click
      puts "Based on your CS Settings, you will have to verify that your email was delivered properly for this test(test 23 Forums)"
  end
end